<%

function cookiehandler(varcookiename)

'first read any existing cookies

  varcookiecookie=Request.Cookies("uclib"+varcookiename)

'now check for url parameters, which would be set if they were submitted settings

  varcookie = Request.QueryString(varcookiename)

'write cookie based on varcookie settings

  if (varcookie="y") then
      varcookie="on"
      varcookiecookie="on"
      Response.Cookies("uclib"+varcookiename)="on"
      Response.Cookies("uclib"+varcookiename).Expires= Date + 365
   end if

   if (varcookie="n") then 
      varcookie="off"
      varcookiecookie="off"
      Response.Cookies("uclib"+varcookiename)="off"
      Response.Cookies("uclib"+varcookiename).Expires= Date + 365
   end if




'if varcookie is null then make it equal to varcookiecookie which could still be null

   if varcookie="" then
     varcookie=varcookiecookie
   end if

'make varcookie on by default except for other
   if not varcookiename="other" then
     if not varcookie="off" then
       varcookie="on"
      end if
    else
      if not varcookie="on" then
        varcookie="off"
      end if
    end if

'write cookie

     Response.Cookies("uclib"+varcookiename)=varcookie
     Response.Cookies("uclib"+varcookiename).Expires= Date + 365

'now special check for other
 
if varcookiename="other" then
  varcookieurlcookie=Request.Cookies("uclibotherurl")
  varcookieothernamecookie=Request.Cookies("uclibothername")

  varcookieurl = Request.QueryString("otherurl")

  varcookieothername = Request.QueryString("othername")

  if varcookieurl="" then 
   varcookieurl=varcookieurlcookie
  end if
  
  if varcookieothername="" then 
   varcookieothername=varcookieothernamecookie
  end if

  if not (varcookieurl="") then 
    response.cookies("uclibotherurl")=varcookieurl
    Response.Cookies("uclibotherurl").Expires= Date + 3650
  end if

  if not (varcookieothername="") then 
    response.cookies("uclibothername")=varcookieothername
    Response.Cookies("uclibothername").Expires= Date + 3650
  end if

end if

'now return value of on or off

cookiehandler=varcookie

end function


   varsettings = Request.QueryString("showsettings")
   if not varsettings="1" then
      varsettings="0"
   end if

%>

<%

function cookiehandlerfirst(varcookiename)

'first read existing cookie

  varcookiecookie=Request.Cookies("uclibfirst")

'now check for url parameters, which would be set if they were submitted settings

  varcookie = Request.QueryString(varcookiename)

'if varcookie is null then make it equal to varcookiecookie which could still be null

   if varcookie="" then
     varcookie=varcookiecookie
   end if

'make varcookie Catalog by default
     if varcookie="" then
       varcookie="catalog"
      end if

'write cookie

     Response.Cookies("uclibfirst")=varcookie
     Response.Cookies("uclib"+varcookiename).Expires= Date + 365

'now return value

cookiehandlerfirst=varcookie

end function
%>



<% if varsettings="1" then %>



<%= Request.ServerVariables("URL") %>

<% if cookiehandler("catalog")="on" then %>
<% else %>
<% end if %>


<% if cookiehandlerfirst("first")="journals" then %>


<% varcookieurl=Request.Cookies("uclibotherurl")
 if not (varcookieurl="") then
%>


<%
  varcookieothername=Request.Cookies("uclibothername")
  if not (varcookieothername="") then
%>


<% select case cookiehandlerfirst("first")
     case "catalog"


<% varcount=0 
   vardiv=false
%>


<% if cookiehandler("uclibs")="on" then 
   varcount=varcount+1
%>


<% if cookiehandler("help")="on" then
     varcount=varcount+1
     if (varcount >5) and (vardiv=false) then 
       vardiv=true
%>


<% if cookiehandler("other")="on" then
     varcookieurl=Request.Cookies("uclibotherurl")
     if not (varcookieurl = "") then
       varcookieothername=Request.Cookies("uclibothername") 
       if varcookieothername="" then
         varcookieothername=varcookieurl
       end if
     end if

     varcount=varcount+1
     if (varcount >5) and (vardiv=false) then 
       vardiv=true
%>
      if cookiehandler("catalog")="on" then %>